﻿using UnityEngine;
using UnityEngine.UI;

public class HomeController : MonoBehaviour
{
    public GameObject SetName;
    public InputField NameInput;
    public Text HelloText;

    private void Start()
    {
        Settings config = ConfigManager.LoadSettings();
        HelloText.text = string.Format("你好，{0}", config.Username);
        if (config.FirstTime)
        {
            SetName.SetActive(true);
            config.FirstTime = false;
            ConfigManager.SaveSettings(config);
        }
        else SetName.SetActive(false);
    }

    public void ConfirmName()
    {
        Settings config = ConfigManager.LoadSettings();
        config.Username = NameInput.text;
        ConfigManager.SaveSettings(config);
        SetName.SetActive(false);
        HelloText.text = string.Format("你好，{0}", config.Username);
    }
}
